package jdk.collection.concurrent;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;

public class CopyOnWriteArrayListDemo {
    public static void main(String[] args) {
        List list = new CopyOnWriteArrayList();
        list.add("name");
        list.add("sex");
        list.get(0);
        list.set(1, "mm");
        list.iterator();
        list.listIterator();



        CopyOnWriteArrayList list2 = new CopyOnWriteArrayList();
        list2.addIfAbsent("luobinjie");


        /**
         * 就是copyOnWriteArrayList在普通add操作也要进行Absent判断。
         */
        CopyOnWriteArraySet set = new CopyOnWriteArraySet();
        set.add("null");
        System.out.println(list);
    }
}
